package cn.tx.redis7.test;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

/**
 * @author jizenan
 * @date 2025/6/5
 * Description:
 */
public class GuavaDemo {
    public static void main(String[] args) {
        //1 创建guava版的布隆过滤器
        BloomFilter<Integer> bloomFilter = BloomFilter.create(Funnels.integerFunnel(), 100);
        //2 判断指定的元素是否存在
        System.out.println(bloomFilter.mightContain(1));
        System.out.println(bloomFilter.mightContain(2));

        //3 将元素新增进bloomfilter
        bloomFilter.put(1);
        bloomFilter.put(2);
        System.out.println(bloomFilter.mightContain(1));
        System.out.println(bloomFilter.mightContain(2));
    }
}
